﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Expo.Training.DataAccess.Vip;

public partial class Vip_LevelManagement : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Bind();
        }
    }

    private void Bind()
    {
        this.rpt_Levels.DataSource = VipModule.GetLevels(string.Empty, string.Empty);
        this.rpt_Levels.DataBind();
    }

    protected void rpt_Levels_ItemCommand(object sender, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "delete")
        {
            Guid _id = new Guid(e.CommandArgument.ToString());

            if (VipModule.DeleteLevel(_id))
            {
                this.AddEndScript("delete succes", "alert('删除等级成功！');location.href='LevelManagement.aspx'");
            }
            else
            {
                this.AddEndScript("error", "alert('删除操作出错，请重试！');");
            }

            Bind();
        }
    }
}
